package com.lzl.controller;

import com.lzl.responese.ResponseResult;
import com.lzl.request.VerificationCodeDTO;
import com.lzl.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * //TODO
 *
 * @author zhaolinlin
 * @description //TODO
 * @createTime 2022/7/31 17:35
 */

@RestController
public class UserController {
    @Autowired
    UserService userService;

    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){
        //获取用户手机号码
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        return userService.loginOrRegister(passengerPhone);
    }

    @GetMapping("/users/{phone}")
    public ResponseResult getUserByPhone(@PathVariable("phone") String phone){
        return userService.getUserByPhone(phone);
    }
}
